package com.anjie.powerproject.strategy.service;

import com.anjie.powerproject.entity.StrategyOutput;
import com.anjie.powerproject.repository.StrategyOutputRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class StrategyOutService {
    @Resource
    private StrategyOutputRepository strategyOutRepository;

    @Transactional
    public void insertAll(List<StrategyOutput> strategyOutputs) {
        strategyOutRepository.saveAll(strategyOutputs);
    }

    public List<StrategyOutput> getStrategyOutputsByDateAndType(Date date, Integer type, Integer graphId) {
        return strategyOutRepository.findStrategyOutputsByDateAndType(date, type, graphId);
    }
    //策略的结束时间在yesterday-17.30 —— today17.30之间 且 开始时间和结束时间在yesterday和today两天内
    public List<StrategyOutput> getStrategyOutputsByDateAndTypeAndEndTime(Integer type, Integer graphId,String yesterdayEndWorkTime,String endWorkTime) {
        return strategyOutRepository.findStrategyOutputsByDateAndTypeAndEndTime(type, graphId,yesterdayEndWorkTime,endWorkTime);
    }
    //策略的开始时间在yesterday-17.30 —— today17.30之间 且 开始时间和结束时间在yesterday和today两天内
    public List<StrategyOutput> getStrategyOutputsByDateAndTypeAndStartTime(Date today, Date yesterday, Integer type, Integer graphId,String yesterdayEndWorkTime,String endWorkTime) {
        return strategyOutRepository.findStrategyOutputsByDateAndTypeAndStartTime(today, yesterday, type, graphId,yesterdayEndWorkTime,endWorkTime);
    }

}